Imports DaveSexton.DocProject.DocSites

Partial Public Class DocSiteHeader
	Inherits System.Web.UI.UserControl

	Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
		chmHyperLink.NavigateUrl = DocSiteManager.Settings.CompiledHelp1xFilePath

		MyBase.OnInit(e)
	End Sub

	Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
		MyBase.OnLoad(e)

		If Not Page.IsPostBack Then
			Dim authenticated As Boolean = Page.User.Identity.IsAuthenticated

			searchImageButton.Visible = authenticated OrElse DocSiteManager.Settings.SearchEnabled
			browseImageButton.Visible = authenticated OrElse DocSiteManager.Settings.BrowseIndexEnabled

			If Not searchImageButton.Visible AndAlso Not browseImageButton.Visible Then
				searchTextBox.Visible = False
			End If
		End If

		Page.Form.DefaultButton = searchImageButton.UniqueID
		searchTextBox.Focus()
	End Sub

	Protected Sub searchImageButton_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs)
		DocSiteNavigator.NavigateToSearchResults(searchTextBox.Text)
	End Sub

	Protected Sub browseImageButton_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs)
		DocSiteNavigator.NavigateToBrowseIndex(searchTextBox.Text)
	End Sub
End Class